<?php
/**
 * Created by PhpStorm.
 * User: helloxingtongshi
 * Date: 2016-06-07
 * Time: 16:47
 */
//获取系统时间
date_default_timezone_set("PRC");
$h=date("H");//格式化本地时间或日期
$i=date("i");
$s=date("s");
//创建资源--画布大小
$img=imagecreatetruecolor(200,250);
//设置画布的颜色
$white=imagecolorallocate($img,0xFF,0xFF,0xFF);
$red=imagecolorallocate($img,255,0,0);
$blue=imagecolorallocate($img,0,0,0xFF);
$pink=imagecolorallocate($img,0xFF,0,0xFF);
$green=imagecolorallocate($img,0,0xFF,0);

imagefill($img,0,0,$red);
//制作各种颜色//画出各种图形
imageellipse($img,100,100,190,190,$blue);
imagefilledellipse($img,100,100,4,4,$blue);
imagestring($img,3,95,8,"12",$white);
imagestring($img,3,180,95,"03",$white);
imagestring($img,3,95,180,"06",$white);
imagestring($img,3,11,95,"09",$white);
//秒针
$len=80;
$a = $len*sin(pi()/30*$s);
$b = $len*cos(pi()/30*$s);
$x = 100 + $a;
$y = 100 - $b;
imageline($img, 100, 100, $x, $y, $blue);
//数字的时间
imagestring($img, 5, 20, 230, "NOW: {$h}:{$i}:{$s}", $white);
//4保存，或输出给浏览, 写第二个参数就是保存
header("Content-Type:images/gif");
imagegif($img);
//5. 释放资源
imagedestroy($img);

?>